<template>
	<view>
		<u-tabs itemStyle="width: 44.5%; background-color: #ffffff; height: 36px;" :list="list1" @click="click">
		</u-tabs>
		<mescroll-body ref="mescrollRef" height="60%" @init="mescrollInit" @up="upCallback" @down="downCallback">
			<goodslist :list="list"></goodslist>
		</mescroll-body>
		<zero-back-top :scrollTop="scrollTop"></zero-back-top>
	</view>
</template>

<script>
	import goodslist from '@/components/goodslist'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		components: {
			goodslist
		},
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		data() {
			return {
				params: {},
				list: [],
				list1: [{
					name: 'All',
				}, {
					name: 'Latest',
				}],
				index: 0,
				scrollTop: 0,
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop
		},
		onLoad(params) {
			this.params = params
			this.getgoods()
		},
		methods: {
			click(item) {
				console.log('item', item);
				this.index = item.index
				this.getgoods()
			},
			downCallback() {
				// 下拉回调
				this.getgoods()
			},
			upCallback() {
				// 上拉回调
				return
			},
			getgoods() {
				const params = {
					map: 'applet_goods_list',
					sortType: 6,
					kind1: this.params.id,
					kind2: this.params.id2
				}
				if (this.index == 0) {
					params.sortType = 6
				}
				if (this.index == 1) {
					params.sortType = 5
				}
				this.$Request({
					method: 'GET',
					data: params
				}).then(res => {
					if (res.data.ec == 200) {
						console.log(res)
						this.list = res.data.data
						this.mescroll.endSuccess(res.data.data.length);
					} else {
						this.mescroll.endSuccess(0);
					}
				})
			}
		},
	}
</script>

<style lang="scss">
</style>
